<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>在线考试平台</title>
    <link rel="shortcut icon" href="static/layui/images/exam.png" type="image/x-icon">
    <link rel="stylesheet" href="static/layui/css/font.css">
    <link rel="stylesheet" href="static/layui/css/xadmin.css">
    <script src="static/layui/lib/layui/layui.js"></script>
    <script src="static/layui/js/xadmin.js"></script>
    <script src="static/layui/js/jquery.min.js"></script>

</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-sm12 layui-col-md10 layui-col-md-offset1">
            <div class="layui-card">
                <div class="layui-card-header" style="background: #00F7DE">
                    <span style="float: left" id="e_name">
                    </span>
                </div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space15">
                        <div class="layui-col-sm12 layui-col-md6 layui-col-md-offset3">

                        </div>
                    </div>
                    <div class="layui-row layui-col-space15" id="question_list">

                    </div>

                </div>

            </div>
        </div>
    </div>
</div>

</body>

<script>
    layui.use(['element', "form", 'jquery', 'layer', 'util'], function () {
        const form = layui.form;
        const $ = layui.jquery;
        const layer = layui.layer;
        const element = layui.element;
        var util = layui.util;
        header(element)
        get_exam_paper_by_ep_id();
        util.fixbar({
            top: true
            , css: {right: 15, bottom: 35}
            , bgcolor: '#2a96ff !important;display:block;'
            , showHeight: 100
            , click: function (type) {
                if (type === 'top') {
                    $('.layui-body').animate({//主要代码
                        scrollTop: 0
                    }, 200);
                }
            }
        });
    });

    function header(element) {
        var user_json = JSON.parse(sessionStorage.getItem("userJson"));
        var text = ""
        if (user_json === null) {
            location.href = '/exam_system/';
        } else {
            text += "<li class=\"layui-nav-item\">" +
                "                    <a href=\"javascript:;\">" + user_json.u_name + "</a>" +
                "                    <dl class=\"layui-nav-child\">" +
                "                        <dd><a onclick='modify_psw()'>修改密码</a></dd>" +
                "                        <dd><a onclick='user_quit()'>退出</a></dd>" +
                "                    </dl>" +
                "                </li>"
            $("#user-state").html(text)
        }
        element.render('header-user')
    }

    function user_quit() {
        sessionStorage.clear("userJson");
        location.href = '/exam_system/';
    }

    function modify_psw() {
    }


    function get_exam_paper_by_ep_id() {
        layui.use(['layer', 'form'], function () {
            const layer = layui.layer;
            const form = layui.form;
            const ep_id = "${ep_id}";
            $.ajax({
                url: 'get_exam_paper_by_ep_id',
                dataType: "json",//数据格式
                type: "post",//请求方式
                async: false,//是否异步请求
                data: {ep_id: ep_id},
                success: function (data) {
                    if (data.code === 200) {
                        $("#e_name").html(data.result.paper_res.ep_name);
                        var text = "";
                        for (let i = 0; i < data.result.scq_data.length; i++) {
                            text += "<div class=\"layui-col-sm12\" style=\"background: #f7f8fc\">" +
                                "                            <div class=\"layui-card\">"
                                text += "                                <div class=\"layui-card-header\" style='background: gainsboro'>" +
                                    "                                    单选题" +
                                    "                                </div>";
                            text += "                               <div class=\"layui-card-header\">" +
                                "                                       <xmp>" + (i + 1) + "." + data.result.scq_data[i].c_describe + "</xmp>" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-header\">" +
                                "                                        <xmp>A:" + data.result.scq_data[i].c_a + "</xmp>" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-header\">" +
                                "                                        <xmp>B:" + data.result.scq_data[i].c_b + "</xmp>" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-header\">" +
                                "                                        <xmp>C:" + data.result.scq_data[i].c_c + "</xmp>" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-header\">" +
                                "                                        <xmp>D:" + data.result.scq_data[i].c_d + "</xmp>" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-header\">正确答案:" +
                                "                                        " + data.result.scq_data[i].c_answer + "" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-body\">答案解析:" +
                                "" + data.result.scq_data[i].c_analysis + "" +
                                "                                    </div>" +
                                "                            </div>" +
                                "                        </div>";
                        }
                        for (let i = 0; i < data.result.jq_data.length; i++) {
                            text += "<div class=\"layui-col-sm12\" style=\"background: #f7f8fc\">" +
                                "                            <div class=\"layui-card\">"
                                text += "                                <div class=\"layui-card-header\" style='background: gainsboro'>" +
                                    "                                    判断题" +
                                    "                                </div>"
                            text += "                                <div class=\"layui-card-header\">" +
                                "                                    <xmp>" + (i + 1) + "." + data.result.jq_data[i].j_describe + "</xmp>" +
                                "                                </div>" +
                                "                                    <div class=\"layui-card-header\">正确答案:" +
                                "                                        " + data.result.jq_data[i].j_answer + "" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-body\">答案解析:" +
                                "" + data.result.jq_data[i].j_analysis + "" +
                                "                                    </div>" +
                                "                            </div>" +
                                "                        </div>";
                        }

                        for (let i = 0; i < data.result.fbq_data.length; i++) {
                            text += "<div class=\"layui-col-sm12\" style=\"background: #f7f8fc\">" +
                                "                            <div class=\"layui-card\">"
                            text += "                                <div class=\"layui-card-header\" style='background: gainsboro'>" +
                                "                                    填空题(正确答案，分割)" +
                                "                                </div>"
                            text += "                                <div class=\"layui-card-header\">" +
                                "                                    <xmp>" + (i + 1) + "." + data.result.fbq_data[i].fb_describe + "</xmp>" +
                                "                                </div>" +
                                "                                    <div class=\"layui-card-header\">正确答案:" +
                                "                                    <xmp>" + data.result.fbq_data[i].fb_answer + "</xmp>" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-body\">答案解析:" +
                                "" + data.result.fbq_data[i].fb_analysis + "" +
                                "                                    </div>" +
                                "                            </div>" +
                                "                        </div>";
                        }


                        for (let i = 0; i < data.result.saq_data.length; i++) {
                            text += "<div class=\"layui-col-sm12\" style=\"background: #f7f8fc\">" +
                                "                            <div class=\"layui-card\" >"
                            text += "                                <div class=\"layui-card-header\" style='background: gainsboro'>" +
                                "                                    简答题" +
                                "                                </div>"
                            text += "                                <div class=\"layui-card-header\">" +
                                "                                    <xmp>" + (i + 1) + "." + data.result.saq_data[i].sa_describe + "</xmp>" +
                                "                                </div>" +
                                "                                    <div class=\"layui-card-body\">正确答案:" +
                                "" + data.result.saq_data[i].sa_answer + "" +
                                "                                    </div>" +
                                "                                    <div class=\"layui-card-body\">答案解析:" +
                                "" + data.result.saq_data[i].sa_analysis + "" +
                                "                                    </div>" +
                                "                            </div>" +
                                "                        </div>";
                        }
                        $("#question_list").html(text);
                    } else {

                    }
                },
                error: function (e) {
                    alert("出现错误！！");
                }
            });
        })
    }
</script>
</html>